
#include "PersonalWidget.h"
#include "IdDocs.h"

PersonalWidget::PersonalWidget(QWidget* parent, InfoDoc* idocs)
: QWidget(parent, 0) {

    box = new QWidget(this);
    box->setObjectName(QString::fromUtf8("box"));
    QSizePolicy sizePolicy1(QSizePolicy::Ignored, QSizePolicy::Maximum);
    sizePolicy1.setHorizontalStretch(0);
    sizePolicy1.setVerticalStretch(0);
    sizePolicy1.setHeightForWidth(box->sizePolicy().hasHeightForWidth());
    box->setSizePolicy(sizePolicy1);
    box->setStyleSheet(QString::fromUtf8(""));

    QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed);
    sizePolicy2.setHorizontalStretch(0);
    sizePolicy2.setVerticalStretch(0);

    precedent = new QLabel(box);
    precedent->setObjectName(QString::fromUtf8("precedent"));
    sizePolicy2.setHeightForWidth(precedent->sizePolicy().hasHeightForWidth());
    precedent->setSizePolicy(sizePolicy2);
    precedent->setStyleSheet(QString::fromUtf8("font: 75 11pt \"Ubuntu\";"));

    title = new QPushButton(box);
    title->setObjectName(QString::fromUtf8("title"));
    sizePolicy2.setHeightForWidth(title->sizePolicy().hasHeightForWidth());
    title->setSizePolicy(sizePolicy2);
    QFont font2;
    font2.setFamily(QString::fromUtf8("Times New Roman"));
    font2.setPointSize(12);
    font2.setBold(false);
    font2.setItalic(false);
    font2.setUnderline(true);
    font2.setWeight(9);
    title->setFont(font2);
    title->setMouseTracking(false);
    title->setLayoutDirection(Qt::LeftToRight);
    title->setStyleSheet(QString::fromUtf8("font: 75 12pt \"Times New Roman\";\n"
            "text-decoration: underline;\n"
            "color: rgb(0, 0, 255);"));
    title->setAutoDefault(false);
    title->setDefault(false);
    title->setFlat(true);

    space = new QLabel(box);
    space->setObjectName(QString::fromUtf8("space"));

    identification = new QLabel(box);
    identification->setObjectName(QString::fromUtf8("identification"));
    QSizePolicy sizePolicy3(QSizePolicy::Preferred, QSizePolicy::Maximum);
    sizePolicy3.setHorizontalStretch(0);
    sizePolicy3.setVerticalStretch(0);
    sizePolicy3.setHeightForWidth(identification->sizePolicy().hasHeightForWidth());
    identification->setSizePolicy(sizePolicy3);

    perc = new QLabel(box);
    perc->setObjectName(QString::fromUtf8("perc"));
    QSizePolicy sizePolicy4(QSizePolicy::Preferred, QSizePolicy::Maximum);
    sizePolicy4.setHorizontalStretch(0);
    sizePolicy4.setVerticalStretch(0);
    sizePolicy4.setHeightForWidth(perc->sizePolicy().hasHeightForWidth());
    perc->setSizePolicy(sizePolicy4);

    QVBoxLayout* verticalLayout = new QVBoxLayout(box);
    verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));

    QHBoxLayout* horizontalLayout = new QHBoxLayout();
    horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));

    horizontalLayout->addWidget(precedent);
    horizontalLayout->addWidget(title);
    horizontalLayout->addWidget(space);

    verticalLayout->addLayout(horizontalLayout);
    verticalLayout->addWidget(identification);
    verticalLayout->addWidget(perc);

    file = idocs->File;
    QObject::connect(title, SIGNAL(clicked()), this, SLOT(open_file()));

    QString* a = new QString();
    std::string cad;
    a->setNum(idocs->Precedent);
    precedent->setText(a->toStdString().c_str());
    title->setText(idocs->Title.c_str());
    a->setNum(idocs->Identification);
    cad = "id// " + a->toStdString();
    identification->setText(cad.c_str());
    a->setNum(idocs->Perc);
    cad = a->toStdString() + "%";
    perc->setText(cad.c_str());
}

void PersonalWidget::open_file() {
    std::string comando = "gedit " + file;
    system(comando.c_str());
}
